package com.example.bingobox.model;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.LinkedHashSet;
import java.util.stream.Collectors;

public class TodoBox {
    private String id;
    private String name;
    private String description;
    private long deadline;
    private transient boolean expanded = false;
    private ListData listData;
    private List<Task.TimeLabel> timeLabels;
    private List<String> locationTypes = new ArrayList<>();
    private List<String> networkTypes = new ArrayList<>(Arrays.asList("Wifi", "流量", "无网络")); // 默认全选
    private List<String> moods = new ArrayList<>();
    private List<String> healthStates = new ArrayList<>();
    private Set<String> scenes = new LinkedHashSet<>();
    private boolean visible = true;

    public TodoBox() {
        this.listData = new ListData();
        this.timeLabels = new ArrayList<>();
    }

    public static class ListData {
        private List<TaskRef> list = new ArrayList<>();

        public ListData() {}

        public List<TaskRef> getList() { return list; }
        public void setList(List<TaskRef> list) { this.list = list; }
    }

    public static class TaskRef {
        private String taskId;
        private String name;
        private long deadline;

        public TaskRef() {}

        public String getTaskId() { return taskId; }
        public void setTaskId(String taskId) { this.taskId = taskId; }
        
        public String getName() { return name; }
        public void setName(String name) { this.name = name; }
        
        public long getDeadline() { return deadline; }
        public void setDeadline(long deadline) { this.deadline = deadline; }
    }

    public String getId() { return id; }
    public void setId(String id) { this.id = id; }
    
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    
    public String getDescription() { return description; }
    public void setDescription(String description) { this.description = description; }
    
    public long getDeadline() { return deadline; }
    public void setDeadline(long deadline) { this.deadline = deadline; }
    
    public boolean isExpanded() { return expanded; }
    public void setExpanded(boolean expanded) { this.expanded = expanded; }
    
    public ListData getListData() { return listData; }
    public void setListData(ListData listData) { this.listData = listData; }
    
    public List<Task.TimeLabel> getTimeLabels() { return timeLabels; }
    public void setTimeLabels(List<Task.TimeLabel> timeLabels) { this.timeLabels = timeLabels; }

    public List<String> getLocationTypes() {
        return locationTypes;
    }

    public void setLocationTypes(List<String> locationTypes) {
        this.locationTypes = locationTypes;
    }

    public List<String> getNetworkTypes() {
        return networkTypes;
    }

    public void setNetworkTypes(List<String> networkTypes) {
        this.networkTypes = networkTypes;
    }

    public List<String> getMoods() {
        return moods;
    }

    public void setMoods(List<String> moods) {
        this.moods = moods;
    }

    public List<String> getHealthStates() {
        return healthStates;
    }

    public void setHealthStates(List<String> healthStates) {
        this.healthStates = healthStates;
    }

    public Set<String> getScenes() {
        return scenes;
    }

    public void setScenes(Set<String> scenes) {
        this.scenes = scenes != null ? scenes : new LinkedHashSet<>();
    }

    public boolean isVisible() {
        return visible;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    public List<String> getTaskIds() {
        if (listData != null && listData.getList() != null) {
            return listData.getList().stream()
                .map(TaskRef::getTaskId)
                .collect(Collectors.toList());
        }
        return new ArrayList<>();
    }
} 